<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="resources/css/bootstrap.min.css" />
  <link rel="stylesheet" href="resources/css/bootstrap-responsive.min.css" />
  <link rel="stylesheet" href="resources/css/matrix-login.css" />
  <link href="resources/font-awesome/css/font-awesome.css" rel="stylesheet" />
  <link rel="stylesheet" href="resources/css/jquery.gritter.css" />
  <link rel="icon" href="resources/img/icon.png" sizes="512x512">
</head>
<body>
<h3>用户管理（管理端）</h3><br>
<button id="adduser">添加用户</button>
<button id="updateuser">更新用户</button>
<button id="deleteuser">删除用户</button>
<h3>用户角色</h3>
<button id="addroleforuser">赋予角色</button>
<button id="updateroleforuser">更新角色</button>
<button id="recorolefromuser">回收角色</button>


<br>
<h3><a href="./">角色权限管理</a></h3>
</body>
<script src="resources/js/jquery.min.js"></script>
<script src="resources/js/matrix.login.js"></script>
<script src="resources/js/jquery.gritter.min.js"></script>
<script src="resources/js/vue.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	
	$("#adduser").click(adduser);
	$("#updateuser").click(updateuser);
	$("#deleteuser").click(deleteuser);
	$("#addroleforuser").click(addroleforuser);
	$("#updateroleforuser").click(updateroleforuser);
	$("#recorolefromuser").click(recorolefromuser);
	

});

function adduser(){
	$.ajax("./manage/user/save", 
			{
			dataType : "json", 
   			type : "post", 
		   contentType:"application/json", 
		   data:JSON.stringify({"username":"js01","password":"js01","userType":"教师"}),
		   success :function(data){
			   console.log(data);
		   },
		   error:function(){
			   alert("数据发送失败");
		   }
	});
}

function updateuser(){
	$.ajax("./manage/user/update", 
			{
			dataType : "json", 
   			type : "post", 
		   contentType:"application/json", 
		   data:JSON.stringify({"userId":"FCAE928E0F0E4D37B67BEA423CB5BDCC","username":"js01","password":"js01","userType":"教师"}),
		   success :function(data){
			   console.log(data);
		   },
		   error:function(){
			   alert("数据发送失败");
		   }
	});
}

function deleteuser(){
	$.ajax("./manage/user/delete", 
			{
			dataType : "json", 
   			type : "post", 
		   contentType:"application/json", 
		   data:JSON.stringify({"userId":"FCAE928E0F0E4D37B67BEA423CB5BDCC"}),
		   success :function(data){
			   console.log(data);
		   },
		   error:function(){
			   alert("数据发送失败");
		   }
	});
}

function addroleforuser(){
	$.ajax("./manage/user/role/save", 
			{
			dataType : "json", 
   			type : "post", 
		   contentType:"application/json", 
		   data:JSON.stringify({"userId":"CE70FDA484E0449D8676FD85660F51B7","roleId":"D895D0759CA542FCBDDE858A6C2DE901"}),
		   success :function(data){
			   console.log(data);
		   },
		   error:function(){
			   alert("数据发送失败");
		   }
	});
}

function updateroleforuser(){
	$.ajax("./manage/user/role/update", 
			{
			dataType : "json", 
   			type : "post", 
		   contentType:"application/json", 
		   data:JSON.stringify({"relId":"21DF9C02E4AB464FB0666A83E69471B2","userId":"CE70FDA484E0449D8676FD85660F51B7","roleId":"D895D0759CA542FCBDDE858A6C2DE901"}),
		   success :function(data){
			   console.log(data);
		   },
		   error:function(){
			   alert("数据发送失败");
		   }
	});
}

function recorolefromuser(){
	$.ajax("./manage/user/role/recycle", 
			{
			dataType : "json", 
   			type : "post", 
		   contentType:"application/json", 
		   data:JSON.stringify({"relId":"21DF9C02E4AB464FB0666A83E69471B2"}),
		   success :function(data){
			   console.log(data);
		   },
		   error:function(){
			   alert("数据发送失败");
		   }
	});
}


</script>
</html>